﻿using IMath;

namespace Math
{
    /// <summary>
    /// 基础数学计算器 - 实现IMathOperations接口
    /// </summary>
    public class BasicMathCalculator : IMathOperations
    {
        private readonly string _calculatorName;

        public BasicMathCalculator()
        {
            _calculatorName = "基础数学计算器";
        }

        public BasicMathCalculator(string name)
        {
            _calculatorName = name;
        }

        public double Add(double a, double b)
        {
            return a + b;
        }

        public double Subtract(double a, double b)
        {
            return a - b;
        }

        public double Multiply(double a, double b)
        {
            return a * b;
        }

        public double Divide(double a, double b)
        {
            if (b == 0)
            {
                throw new DivideByZeroException("除数不能为零！");
            }
            return a / b;
        }

        public string GetCalculatorName()
        {
            return _calculatorName;
        }
    }
}